package com.work.washer.model;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * @TableName goods
 */
@TableName(value = "goods")
@Data
public class Goods implements Serializable {
    /**
     *
     */
    @TableId(type = IdType.AUTO)
    private Integer id;

    /**
     *
     */
    @JsonProperty("class_field")
    private Integer classId;

    /**
     * 标题
     */
    private String title;

    /**
     * 价格
     */
    private BigDecimal price;

    /**
     * 主图
     */
    private String thumb;

    public String getThumb() {
        return "http://localhost:8080/erupt-attachment"+thumb;
    }

    /**
     * 创建人id
     */
    @JsonProperty("user")
    private Integer userId;

    /**
     *
     */
    @JsonProperty("create_time")
    private Date createTime;

    /**
     *
     */
    private String detail;

    public String getDetail() {
        return detail.replace("|", ",").replaceFirst("/", "http://localhost:8080/erupt-attachment")
                .replace(",/", ",http://localhost:8080/erupt-attachment/");
    }

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;
}